package com.drojian.demo4;

import android.content.Intent;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.drojian.demo.R;
import com.drojian.demo4.communication.BroadcastReceiverActivity;
import com.drojian.demo4.communication.ContentProviderActivity;
import com.drojian.demo4.communication.EventBusActivity;
import com.drojian.demo4.communication.HandlerActivity;
import com.drojian.demo4.communication.HandlerThreadActivity;
import com.drojian.demo4.communication.RxBusActivity;


public class CommunicationFragment extends Fragment {

    private View view;

    public static CommunicationFragment newInstance() {
        return new CommunicationFragment();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.part4_fragment_communication, container, false);
        Button btn1 = view.findViewById(R.id.btn1);
        Button btn2 = view.findViewById(R.id.btn2);
        Button btn3 = view.findViewById(R.id.btn3);
        Button btn4 = view.findViewById(R.id.btn4);
        Button btn5 = view.findViewById(R.id.btn5);
        Button btn6 = view.findViewById(R.id.btn6);
        Button btn7 = view.findViewById(R.id.btn7);
        btn1.setOnClickListener(v->startActivity(new Intent(getContext(), HandlerActivity.class)));
        btn2.setOnClickListener(v->startActivity(new Intent(getContext(), HandlerThreadActivity.class)));
        btn3.setOnClickListener(v->startActivity(new Intent(getContext(), ContentProviderActivity.class)));
        btn4.setOnClickListener(v->startActivity(new Intent(getContext(), BroadcastReceiverActivity.class)));
        btn6.setOnClickListener(v->startActivity(new Intent(getContext(), EventBusActivity.class)));
        btn7.setOnClickListener(v->startActivity(new Intent(getContext(), RxBusActivity.class)));

        return view;
    }
}